package com.neuedu.web.utils;

import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;

/**
 * @author 金山
 * 项目：javaweb
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2024/11/1816:58
 */
public class BeanConvertUtils {


    public static <T> T conver(Class<T> clazz ,Object obj){

        Object dest = null;
        try {

            dest = clazz.newInstance();
            BeanUtils.copyProperties(dest,obj);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        }

        return (T) dest;
    }

}
